﻿using RimWorld;
using Verse;

namespace RimZombieGirl
{
    public abstract class IncidentWorker_GiveDaoNeutralBase : IncidentWorker
    {
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
                return false;

            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("RI_Faction_Dao"));
            if (faction == null)
                return false;

            // 只在中立关系时触发
            return faction.RelationKindWith(Faction.OfPlayer) == FactionRelationKind.Neutral;
        }

        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = parms.target as Map;
            if (map == null)
                return false;

            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("RI_Faction_Dao"));
            if (faction == null)
                return false;

            //由子类实现具体事件内容
            return ExecuteNeutralEvent(parms, map, faction);
        }

        protected abstract bool ExecuteNeutralEvent(IncidentParms parms, Map map, Faction daoFaction);
    }
}
